<#include "header.htm"/>
<script type="text/javascript" src="${JForumContext.encodeURL("/js/list/moderation")}"></script>

<#import "../macros/pagination.ftl" as topicPagination>
<#import "../macros/search_pagination.ftl" as pagination>
<#import "../macros/presentation.ftl" as presentation/>

<table cellspacing="0" cellpadding="10" width="100%" align="center" border="0">
  <tr>
    <td class="bodyline" valign="top">
      <table cellspacing="2" cellpadding="2" width="100%" align="center" border="0">
        <tr>
          <td valign="bottom" align="left">
		  <span class="maintitle">${I18n.getMessage("Search.searchResults")}:
		  ${totalRecords} <#if (totalRecords == 1)>${I18n.getMessage("Search.recordFound")}<#else>${I18n.getMessage("Search.recordsFound")}</#if>
		  </span>
		 <br/>
            </td>
          <td valign="bottom" nowrap="nowrap" align="right">
		  
		  <@pagination.searchPagination kw?default(""), terms?default(""), forum?default(""), category?default(""), orderField?default(""), orderBy?default(""), author?default(""), postTime?default("")/>
		  </td></tr>
        <tr>
          <td align="left" valign="middle">		  
		    <a class="nav" href="${contextPath}/forums/list${extension}">${I18n.getMessage("ForumListing.forumIndex")}</a>
		</td>
          <td class="nav" valign="bottom" nowrap="nowrap" align="right">
		  <span class="gensmall">
		  <#if (moderator && totalRecords > 0)>
				<#if openModeration?default(false)>
					<#assign mp = pagination.moderationParams("0")/>
					<a href="${contextPath}/jforum${extension}?module=search&amp;action=search&amp;${mp}&amp;start=${start}">${I18n.getMessage("Moderation.CloseModeration")}</a>
				<#else>
					<#assign mp = pagination.moderationParams("1")/>
					<a href="${contextPath}/jforum${extension}?module=search&amp;action=search&amp;${mp}&amp;start=${start}">${I18n.getMessage("Moderation.OpenModeration")}</a>
				</#if>
			</#if>
		  </span></td>
        </tr></table>

<#if moderator>
	<form accept-charset="${encoding}" action="${contextPath}/jforum${extension}" method="post" name="form1">
	<input type="hidden" name="action" value="doModeration" />
	<input type="hidden" name="module" value="${moduleName}" />
	<input type="hidden" name="securityHash" value="${securityHash}" />
	<input type="hidden" name="start" value="${thisPage}" />
	<#assign mp = pagination.moderationParams("")/>
	<input type="hidden" name="persistData" value="${mp}" />
</#if>
		
   <table class="forumline" cellspacing="1" cellpadding="4" width="100%" border="0">
        <tr>
          <th class="thcornerl" nowrap="nowrap" align="center" height="25" width="20">&nbsp;</th>
          <th class="thcornerl" nowrap="nowrap" align="center" height="25">&nbsp;${I18n.getMessage("Forums.Form.ForumName")}&nbsp;</th>
          <th class="thcornerl" nowrap="nowrap" align="center" height="25">&nbsp;${I18n.getMessage("ForumIndex.topics")}&nbsp;</th>
          <th class="thtop" nowrap="nowrap" align="center" width="50">&nbsp;${I18n.getMessage("ForumIndex.answers")}&nbsp;</th>
          <th class="thtop" nowrap="nowrap" align="center" width="100">&nbsp;${I18n.getMessage("ForumIndex.author")}&nbsp;</th>
          <th class="thtop" nowrap="nowrap" align="center" width="50">&nbsp;${I18n.getMessage("ForumIndex.views")}&nbsp;</th>
          <th class="thcornerr" nowrap="nowrap" align="center" width="150">&nbsp;${I18n.getMessage("ForumIndex.lastMessage")}&nbsp;</th>
		  <#if moderator && openModeration?default(false)>
		  	<th class="thcornerr" nowrap="nowrap" align="center">&nbsp;${I18n.getMessage("ForumIndex.moderation")}&nbsp;</th>
		  </#if>
		</tr>        
		<!-- TOPICS LISTING -->
<#list topics as topic>
		<#assign forum = fr.getForum(topic.forumId)/>

		<tr>
          <td class="row1" valign="middle" align="center" width="20">
		 <@presentation.folderImage topic/>
		</td>
		<td class="row1">
			<span class="topictitle">
				<a href="${contextPath}/forums/show/${forum.id}${extension}">${forum.name}</a>
			</span>
		</td>
          <td class="row1">
		  	<span class="topictitle">
				<a href="${contextPath}/posts/list/${topic.id}${extension}"><#if (topic.title?length == 0)>No Subject<#else>${topic.title?html}</#if></a>
			</span>

			<#if topic.paginate>
				<span class="gensmall">
				<br/>
				<@topicPagination.littlePostPagination topic.id, postsPerPage, topic.totalReplies/>
				</span>
			</#if>
		</td>
          <td class="row2" valign="middle" align="center"><span 
            class="postdetails">${topic.totalReplies}</span></td>
          <td class="row3" valign="middle" align="center">
		  	<span class="name"><a href="${contextPath}/user/profile/${topic.postedBy.id}${extension}">${topic.postedBy.username}</a></span>
		</td>
          <td class="row2" valign="middle" align="center">
		  <span class="postdetails">${topic.totalViews}</span></td>
          <td class="row3" valign="middle" nowrap="nowrap" align="center">
		  <#if (topic.lastPostTime?length > 0)>
			  <span class="postdetails">${topic.lastPostTime}<br/>
			  <a href="${contextPath}/user/profile/${topic.lastPostBy.id}${extension}">${topic.lastPostBy.username}</a>
			  
			<#assign startPage = ""/>
			<#if (topic.totalReplies + 1 > postsPerPage)>
				<#assign startPage = ((topic.totalReplies / postsPerPage)?int * postsPerPage) +"/"/>
			</#if>
			<a href="${contextPath}/posts/list/${startPage}${topic.id}${extension}#${topic.lastPostId}"><img src="${contextPath}/templates/${templateName}/images/icon_latest_reply.gif" border="0" alt="[Latest Reply]" /></a></span>
			</#if>
		 </td>
		  <#if moderator && openModeration?default(false)>
			 <td class="row2" valign="middle" align="center">
			 <input type="checkbox" name="topic_id" value="${topic.id}" />
			 </td>
		 </#if>
        </tr>
</#list>		
		<!-- END OF TOPICS LISTING -->
		
        <tr>
          <td class="catbottom" valign="middle" align="right" colspan="<#if moderator && openModeration?default(false)>8<#else>7</#if>" height="28">&nbsp;
		  <@presentation.moderationButtons/>
		  </td>
        </tr></table>
		
		<#if moderator></form></#if>
		
      <table cellspacing="2" cellpadding="2" width="100%" align="center" border="0">
        
        <tr>
          <td align="left" valign="middle">		  <span class="nav">&nbsp;&nbsp;&nbsp;
		  	<a class="nav" href="${contextPath}/forums/list${extension}">${I18n.getMessage("ForumListing.forumIndex")}</a></span></td>
          <td valign="middle" nowrap="nowrap" align="right">
		  
		  <@pagination.searchPagination kw?default(""), terms?default(""), forum?default(""), category?default(""), orderField?default(""), orderBy?default(""), author?default(""), postTime?default("")/>
		  
		  </td>
        </tr>
        <tr>
          <td align="left" colspan="2"></td></tr></table>
		 
      <table cellspacing="0" cellpadding="0" width="100%" border="0">
       
        <tr>
          <td align="right">
            <table cellspacing="0" cellpadding="0" border="0">
              
              <tr>			  
                <td nowrap="nowrap"><form action="" accept-charset="${encoding}" name="f"><span class="gensmall">${I18n.getMessage("ForumIndex.goTo")}:&nbsp;<select onchange="if(this.options[this.selectedIndex].value != -1){ document.location = '${contextPath}/forums/show/'+ this.options[this.selectedIndex].value +'${extension}'; }" name="select">
				<option value="-1" selected="selected">${I18n.getMessage("ForumIndex.goToSelectAForum")}</option>				
				<#list categories as category>
					<option value="-1">&nbsp;</option>
					<option value="-1">${category.name}</option>
					<option value="-1">-------------</option>
					<#list category.getForums() as forum>
					<option value="${forum.id}">${forum.name}</option>
					</#list>
				</#list>
				</select>				  
				  &nbsp;
                <input class="liteoption" type="button" value="${I18n.getMessage("ForumIndex.goToGo")}" onclick="if(document.f.select.options[document.f.select.selectedIndex].value != -1){ document.location = '${contextPath}/forums/show/'+ document.f.select.options[document.f.select.selectedIndex].value +'${extension}'; }" />
		</span>
				</form>
				</td></tr></table></td></tr></table>
      <table cellspacing="0" cellpadding="0" width="100%" align="center" border="0">
				<tr>
					<td valign="top" align="left">
						<table cellspacing="3" cellpadding="0" border="0">
							<tr>
								<td align="left" width="20"><img src="${contextPath}/templates/${templateName}/images/folder_new.gif" alt="[New Folder]"/></td>
								<td class="gensmall">${I18n.getMessage("ForumIndex.newMessages")}</td>
								<td>&nbsp;&nbsp;</td>
								<td align="center" width="20"><img src="${contextPath}/templates/${templateName}/images/folder.gif" alt="[Folder]" /></td>
								<td class="gensmall">${I18n.getMessage("ForumIndex.noNewMessages")}</td>
								<td>&nbsp;&nbsp;</td>
								<td align="center" width="20"><img src="${contextPath}/templates/${templateName}/images/folder_announce.gif" alt="[Announce]"/></td>
								<td class="gensmall">${I18n.getMessage("ForumIndex.announce")}</td>
							</tr>
							
							<tr>
								<td align="center" width="20"><img src="${contextPath}/templates/${templateName}/images/folder_new_hot.gif" alt="[New Hot]" /></td>
								<td class="gensmall">${I18n.getMessage("ForumIndex.newMessagesHot")}</td>
								<td>&nbsp;&nbsp;</td>
								<td align="center" width="20"><img src="${contextPath}/templates/${templateName}/images/folder_hot.gif" alt="[Hot]" /></td>
								<td class="gensmall">${I18n.getMessage("ForumIndex.noNewMessagesHot")}</td>
								<td>&nbsp;&nbsp;</td>
								<td align="center" width="20"><img src="${contextPath}/templates/${templateName}/images/folder_sticky.gif" alt="[Sticky]" /></td>
								<td class="gensmall">${I18n.getMessage("ForumIndex.sticky")}</td>
							</tr>

							<tr>
								<td align="center" width="20"><img src="${contextPath}/templates/${templateName}/images/folder_lock_new.gif" alt="[New Lock]" /></td>
								<td class="gensmall">${I18n.getMessage("ForumIndex.newMessagesBlocked")}</td>
								<td>&nbsp;&nbsp;</td>
								<td align="center" width="20"><img src="${contextPath}/templates/${templateName}/images/folder_lock.gif" alt="[Lock]" /></td>
								<td class="gensmall">${I18n.getMessage("ForumIndex.noNewMessagesBlocked")}</td>
								<td>&nbsp;&nbsp;</td>
								<td colspan="2"></td>
							</tr>
						</table>
					</td>
					<td align="right"><span class="gensmall"></span></td>
				</tr>
			</table>
    </td></tr></table>
<#include "bottom.htm"/>
